package com.itheima.youdianda.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.youdianda.common.R;
import com.itheima.youdianda.entity.YddLink;
import com.itheima.youdianda.service.YddLinkService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/ydd_link")
public class YddLinkController {

    @Autowired
    private YddLinkService yddLinkService;

    //分页查询
    @GetMapping("/list")
    public R<Page> list(String type,int page, int limit){
        log.info("type:{},page:{},limie:{}",type,page,limit);
        //构造分页构造器
        Page pageInfo = new Page(page,limit);
        //构造条件构造器,添加构造条件
        LambdaQueryWrapper<YddLink> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(YddLink::getType,type);
        yddLinkService.page(pageInfo,queryWrapper);
        //执行查询
        return R.success(pageInfo);
    }


    //链接详情
    @GetMapping("/rowInfo")
    public R<String> rowInfo(){

        return null;
    }


    //链接修改
    @PostMapping("/update")
    public R<String> update(){
        return null;
    }


    //链接删除
    @GetMapping("/del")
    public R<String> del(){
        return null;
    }


    //链接添加
    @PostMapping("/add")
    public R<String> add(){
        return null;
    }


    //链接列表
    @GetMapping("/list")
    public R<String> list(){
        return null;
    }
}
